package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fgs.common.widget.itemView.DetailItemView;
import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.enty.CarrierInfo;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2020/8/27
 * @description
 **/
public class CarrierListAdapter extends RecyclerArrayAdapter<CarrierInfo> {

    public CarrierListAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new OrderListViewHolder(parent, R.layout.item_carrier_list);
    }

    private class OrderListViewHolder extends BaseViewHolder<CarrierInfo> {

        private TextView orderNumberTextView;
        private TextView orderStatusTextView;
        private DetailItemView oneDetailItemView;
        private DetailItemView twoDetailItemView;
        private DetailItemView threeDetailItemView;
        private DetailItemView fourDetailItemView;
        private DetailItemView timeDetailItemView;


        public OrderListViewHolder(ViewGroup parent, int res) {
            super(parent, res);
            orderNumberTextView = getView(R.id.item_carrier_list_topLeftTextView);
            orderStatusTextView = getView(R.id.item_carrier_list_topRightTextView);

            oneDetailItemView = getView(R.id.item_carrier_list_oneDetailItemView);
            twoDetailItemView = getView(R.id.item_carrier_list_twoDetailItemView);
            threeDetailItemView = getView(R.id.item_drvier_list_threeDetailItemView);
            fourDetailItemView = getView(R.id.item_carrier_list_fourDetailItemView);
            fourDetailItemView.setVisibility(View.GONE);
            timeDetailItemView = getView(R.id.item_carrier_list_timeDetailItemView);
            addOnClickListener(R.id.item_carrier_list_editButton);
        }

        @Override
        public void setData(CarrierInfo data) {
            super.setData(data);
            //司机姓名
            orderNumberTextView.setText("编号：" + data.carrierno);
            //司机电话
            oneDetailItemView.setTitle("名称：");
            oneDetailItemView.setContent(data.carriername);
            //身份证
            twoDetailItemView.setTitle("身份证号：");
            twoDetailItemView.setContent(data.idcard);
            //默认车辆
            threeDetailItemView.setTitle("联系人：");
            threeDetailItemView.setContent(data.carrieruername);
            //准驾类型
            fourDetailItemView.setTitle("电话：");
            fourDetailItemView.setContent(data.carriertel);
            //创建时间
            timeDetailItemView.setTitle("地址信息：");
            timeDetailItemView.setContent(data.carrierprovince + " " + data.carriercity + " " + data.carriercounty);
            //状态
            if (data.isaudit == 1) {
                orderStatusTextView.setText("已审核");
            } else {
                orderStatusTextView.setText("未审核");
            }

        }
    }

//    private String getAuthStatus(DriverInfo info) {
//
//        String status = "状态：<font color='#f52225'>" + "未审核" + "</font>";
//        if (info == null) {
//            return status;
//        }
//        if (info.isaudit == 0) {
//            status = "状态：<font color='#f52225'>" + "未审核" + "</font>";
//        } else if (info.isaudit == 1) {
//            status = "状态：<font color='#008000'>" + "已审核" + "</font>";
//        } else if (info.isaudit == 2) {
//            status = "状态：<font color='#0000FF'>" + "待审核" + "</font>";
//        }
//        return status;
//
//    }
}
